home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH1 / SRC / AUTO.FRM next >
Text File  |  1996-05-02  |  3KB  |  115 lines

  1. VERSION 4.00
  2. Begin VB.Form AutoForm 
  3.    Caption         =   "AutoRedraw and Paint Events"
  4.    ClientHeight    =   4365
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1800
  7.    ClientWidth     =   7095
  8.    Height          =   5055
  9.    Left            =   1080
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4365
  12.    ScaleWidth      =   7095
  13.    Top             =   1170
  14.    Width           =   7215
  15.    Begin VB.PictureBox PaintPict 
  16.       Height          =   4095
  17.       Left            =   3600
  18.       ScaleHeight     =   269
  19.       ScaleMode       =   3  'Pixel
  20.       ScaleWidth      =   229
  21.       TabIndex        =   1
  22.       Top             =   240
  23.       Width           =   3495
  24.    End
  25.    Begin VB.PictureBox AutoPict 
  26.       AutoRedraw      =   -1  'True
  27.       Height          =   4095
  28.       Left            =   0
  29.       ScaleHeight     =   269
  30.       ScaleMode       =   3  'Pixel
  31.       ScaleWidth      =   229
  32.       TabIndex        =   0
  33.       Top             =   240
  34.       Width           =   3495
  35.    End
  36.    Begin VB.Label Label1 
  37.       Alignment       =   2  'Center
  38.       Caption         =   "Paint Events"
  39.       Height          =   255
  40.       Index           =   1
  41.       Left            =   3600
  42.       TabIndex        =   3
  43.       Top             =   0
  44.       Width           =   3495
  45.    End
  46.    Begin VB.Label Label1 
  47.       Alignment       =   2  'Center
  48.       Caption         =   "AutoRedraw"
  49.       Height          =   255
  50.       Index           =   0
  51.       Left            =   0
  52.       TabIndex        =   2
  53.       Top             =   0
  54.       Width           =   3495
  55.    End
  56.    Begin VB.Menu mnuFile 
  57.       Caption         =   "&File"
  58.       Begin VB.Menu mnuFileExit 
  59.          Caption         =   "E&xit"
  60.       End
  61.    End
  62. End
  63. Attribute VB_Name = "AutoForm"
  64. Attribute VB_Creatable = False
  65. Attribute VB_Exposed = False
  66. Option Explicit
  67.  
  68. ' ***********************************************
  69. ' Draw a grid skipping every other pixel.
  70. ' ***********************************************
  71. Sub DrawPict(pic As PictureBox)
  72. Const Amp = 3
  73. Const PI = 3.14159
  74. Const Per = 4 * PI
  75.  
  76. Dim i As Single
  77. Dim j As Single
  78. Dim hgt As Single
  79. Dim wid As Single
  80.     
  81.     pic.ScaleMode = 3   ' Pixel.
  82.     
  83.     pic.Cls     ' Clear the picture box.
  84.     
  85.     For i = 0 To pic.ScaleHeight Step 4
  86.         pic.CurrentX = 0
  87.         pic.CurrentY = i
  88.         For j = 0 To pic.ScaleWidth
  89.             pic.Line -(j, i + Amp * Sin(j / Per))
  90.         Next j
  91.     Next i
  92.     For i = 1 To hgt Step 2
  93.         pic.Line (0, i)-(wid, i)
  94.     Next i
  95. End Sub
  96.  
  97. Private Sub Form_Load()
  98.     DrawPict AutoPict
  99. End Sub
  100.  
  101. Private Sub Form_Unload(Cancel As Integer)
  102.     End
  103. End Sub
  104.  
  105.  
  106. Private Sub mnuFileExit_Click()
  107.     Unload Me
  108. End Sub
  109.  
  110. Private Sub PaintPict_Paint()
  111.     DrawPict PaintPict
  112. End Sub
  113.  
  114.  
  115.